package org.jrad.util;

import java.io.File;

import org.jrad.model.EntityCrud;

public class MBHelper {
	
	public static String createMB(String packageRoot, EntityCrud entityCrud){
		String puPath = "template"+File.separator+"GenericMB.java";
		String fileInputData = "";
		try {
			fileInputData = JRadHelper.readFile(puPath);
			String entityName = EntityHelper.upFirst(entityCrud.getName());
			fileInputData = fileInputData.replaceAll("<packageRoot>" , packageRoot+".mb");			
			fileInputData = fileInputData.replaceAll("<packageEntity>" , packageRoot+".entity."+entityName);
			fileInputData = fileInputData.replaceAll("<EntityName>" , entityName);
			fileInputData = fileInputData.replaceAll("<EntityVariable>" , entityCrud.getName().toLowerCase());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return fileInputData;
	}
}
